﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using TransactionServer.General_Classes;

namespace TransactionServer.OSActivities77
{

    public sealed class OSGetEntityById77 : CodeActivity
    {
        public InArgument<Context> Context { get; set; }
        public InArgument<string> Connection { get; set; }
        public InArgument<string> Entity { get; set; }
        public InArgument<string> Id { get; set; }
        public InArgument<string[]> Fields { get; set; }

        public OutArgument<Entity> Result { get; set; }

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            Context con = context.GetValue(this.Context);
            string Connection = context.GetValue(this.Connection);
            string Id = context.GetValue(this.Id);
            string Entity = context.GetValue(this.Entity);
            string[] Fields = context.GetValue(this.Fields);

            var ent = new Entity(Connection, Entity, Id);
            var conn = (OSConnector77)con.Connector[Connection];
            conn.lookupFieldsById(ent, Fields);

            context.SetValue(Result, ent);
        }
    }
}
